//
//  ZYBigImgViewCell.m
//  Project_B
//
//  Created by dllo on 15/12/23.
//  Copyright © 2015年 ZY. All rights reserved.
//

#import "ZYBigImgViewCell.h"

@interface ZYBigImgViewCell ()

@property(nonatomic,strong)UILabel *titleLb;
@property(nonatomic,strong)UILabel *contentLb;
@property(nonatomic,strong)UIImageView *imgView;
@property(nonatomic,strong)UILabel *replyLb;

@end

@implementation ZYBigImgViewCell


#pragma mark -
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createSubView];
    }
    return self;
}


#pragma mark - 
-(void)createSubView{
    
    //标题
    self.titleLb = [[UILabel alloc]init];
//    self.titleLb.backgroundColor = [UIColor yellowColor];
    [self.contentView addSubview:self.titleLb];
    self.titleLb.textAlignment = NSTextAlignmentLeft;
    self.titleLb.font = [UIFont boldSystemFontOfSize:15*ADAPT_FONT];
    self.titleLb.textColor = [UIColor colorWithHue:0.67 saturation:0.01 brightness:0.33 alpha:1];
    
    [_titleLb mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.and.top.mas_equalTo(SPACE);
        make.right.mas_equalTo(-SPACE);
        make.height.mas_equalTo(SPACE*1.5);
        
    }];
    
    
    //图片
    self.imgView = [[UIImageView alloc]init];
//    self.imgView.backgroundColor = [UIColor cyanColor];
    [self.contentView addSubview:self.imgView];
    self.imgView.layer.masksToBounds = YES;
    self.imgView.layer.cornerRadius = 3;
    
    [_imgView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self.titleLb.mas_left);
        make.top.equalTo(self.titleLb.mas_bottom).offset(SPACE/2);
        make.right.mas_equalTo(-SPACE);
        make.height.mas_equalTo(BIGIMG_HEIGHT);
    }];
    
    
    
    
    
    //内容
    self.contentLb = [[UILabel alloc]init];
//    self.contentLb.backgroundColor = [UIColor greenColor];
    [self.contentView addSubview:self.contentLb];
    self.contentLb.numberOfLines = 0;
    self.contentLb.font = [UIFont systemFontOfSize:14*ADAPT_FONT];
    self.contentLb.textColor = [UIColor colorWithHue:0.58 saturation:0.01 brightness:0.61 alpha:1];
    
    [_contentLb mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.equalTo(self.imgView.mas_bottom).offset(SPACE/2);
        make.left.equalTo(self.imgView.mas_left);
        make.right.equalTo(self.titleLb.mas_right);
        make.height.mas_equalTo(SPACE);
    
    }];
    
    
    //跟帖
    self.replyLb = [[UILabel alloc]init];
//    self.replyLb.backgroundColor = [UIColor orangeColor];
    [self.contentView addSubview:self.replyLb];
    self.replyLb.font = [UIFont systemFontOfSize:13*ADAPT_FONT];
    self.replyLb.textAlignment = NSTextAlignmentRight;
    _replyLb.textColor = [UIColor colorWithHue:0.58 saturation:0.01 brightness:0.69 alpha:1];
    
    [_replyLb mas_makeConstraints:^(MASConstraintMaker *make) {
       
        make.right.mas_equalTo(-SPACE);
        make.top.equalTo(self.contentLb.mas_bottom).offset(SPACE/2);
        make.width.mas_equalTo(BIGIMG_HEIGHT);
        make.height.mas_equalTo(SPACE);
        
    }];
    
    
}



#pragma mark -
-(void)setModel:(NewestModel *)model{
    _model = model;
    
    self.titleLb.text = model.title;
    [self.imgView sd_setImageWithURL:model.imgsrc placeholderImage:PLACEHOLDER_IMAGE];
    self.contentLb.text = model.digest;
    self.replyLb.text = [NSString stringWithFormat:@"%@跟帖",model.replyCount];
    
}







#pragma mark -
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
